using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AlphaWebsite.Models;

namespace AlphaWebsite.Controllers
{   
    public class WeddingSidesController : Controller
    {
		private readonly IWeddingSidesRepository weddingsidesRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public WeddingSidesController() : this(new WeddingSidesRepository())
        {
        }

        public WeddingSidesController(IWeddingSidesRepository weddingsidesRepository)
        {
			this.weddingsidesRepository = weddingsidesRepository;
        }

        //
        // GET: /WeddingSides/

        public ViewResult Index()
        {
            return View(weddingsidesRepository.All);
        }

        //
        // GET: /WeddingSides/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(weddingsidesRepository.Find(id));
        }

        //
        // GET: /WeddingSides/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /WeddingSides/Create

        [HttpPost]
        public ActionResult Create(WeddingSides weddingsides)
        {
            if (ModelState.IsValid) {
                weddingsidesRepository.InsertOrUpdate(weddingsides);
                weddingsidesRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /WeddingSides/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
             return View(weddingsidesRepository.Find(id));
        }

        //
        // POST: /WeddingSides/Edit/5

        [HttpPost]
        public ActionResult Edit(WeddingSides weddingsides)
        {
            if (ModelState.IsValid) {
                weddingsidesRepository.InsertOrUpdate(weddingsides);
                weddingsidesRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /WeddingSides/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(weddingsidesRepository.Find(id));
        }

        //
        // POST: /WeddingSides/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            weddingsidesRepository.Delete(id);
            weddingsidesRepository.Save();

            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing) {
                weddingsidesRepository.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}

